#include <iostream>
#include <stack>
using namespace std;

const int kMaxN = 3e6 + 10;
const int kMaxAi = 1e9;

int a[kMaxN], ans[kMaxN];
stack<int> s;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[0] = kMaxAi + 1;
  s.push(0);
  for (int i = n; i; i--) {
    for (; a[s.top()] <= a[i]; s.pop());
    ans[i] = s.top();
    s.push(i);
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}